import time
import multiprocessing
import os

def a1(num,aaa):
    for i in range(num):
        print(f'aaa{aaa}')

        print(f'a1: {i}')
        print(f'a1 os: {os.getpid()}')
        time.sleep(1)


def a2(count):
    for i in range(count):
        print(f'a2: {i}')
        print(f'a2 os: {os.getpid()}')
        time.sleep(1)


if __name__ == '__main__':
    # a1()
    # a2()
    # a1aa = multiprocessing.Process(target=a2)
    # a2aa = multiprocessing.Process(target = a2)

    # 可以传参  如果传递元组的话 并且只有一个参数 那么需要设置,
    a1aa = multiprocessing.Process(target=a1,args=(4,2))
    # 如果使用字典  那么需要将key和方法的key一致
    a2aa = multiprocessing.Process(target=a2,kwargs={'count': 5})
    a22aa = multiprocessing.Process(target=a2, kwargs={'count': 5})
    a1aa.start()
    a2aa.start()
    a22aa.start()